diff -Naur fbpdf-20140822/mupdf.c fbpdf-20140822.patched/mupdf.c
--- fbpdf-20140822/mupdf.c	2014-08-21 21:12:00.000000000 -0400
+++ fbpdf-20140822.patched/mupdf.c	2015-09-12 03:24:40.000000000 -0400
@@ -23,11 +23,11 @@
 	int h, w;
 	int x, y;
 
-	if (!(page = fz_load_page(doc->pdf, p - 1)))
+	if (!(page = fz_load_page(doc->ctx, doc->pdf, p - 1)))
 		return 1;
 	fz_rotate(&ctm, rotate);
 	fz_pre_scale(&ctm, (float) zoom / 10, (float) zoom / 10);
-	fz_bound_page(doc->pdf, page, &rect);
+	fz_bound_page(doc->ctx, page, &rect);
 	fz_transform_rect(&rect, &ctm);
 	fz_round_rect(&bbox, &rect);
 	w = MIN_(*cols, rect.x1 - rect.x0);
@@ -37,8 +37,8 @@
 	fz_clear_pixmap_with_value(doc->ctx, pix, 0xff);
 
 	dev = fz_new_draw_device(doc->ctx, pix);
-	fz_run_page(doc->pdf, page, dev, &ctm, NULL);
-	fz_free_device(dev);
+	fz_run_page(doc->ctx, page, dev, &ctm, NULL);
+	fz_drop_device(doc->ctx, dev);
 
 	for (y = 0; y < h; y++) {
 		int xs = y * *cols + (*cols - w) / 2;
@@ -50,7 +50,7 @@
 		}
 	}
 	fz_drop_pixmap(doc->ctx, pix);
-	fz_free_page(doc->pdf, page);
+	fz_drop_page(doc->ctx, page);
 	*cols = w;
 	*rows = h;
 	return 0;
@@ -58,7 +58,7 @@
 
 int doc_pages(struct doc *doc)
 {
-	return fz_count_pages(doc->pdf);
+	return fz_count_pages(doc->ctx, doc->pdf);
 }
 
 struct doc *doc_open(char *path)
@@ -69,7 +69,7 @@
 	fz_try (doc->ctx) {
 		doc->pdf = fz_open_document(doc->ctx, path);
 	} fz_catch (doc->ctx) {
-		fz_free_context(doc->ctx);
+		fz_drop_context(doc->ctx);
 		free(doc);
 		return NULL;
 	}
@@ -78,7 +78,7 @@
 
 void doc_close(struct doc *doc)
 {
-	fz_close_document(doc->pdf);
-	fz_free_context(doc->ctx);
+	fz_drop_document(doc->ctx, doc->pdf);
+	fz_drop_context(doc->ctx);
 	free(doc);
 }
